#pragma once
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;


template<class T>
class sequence
{
public:
	void Insert(const T& val)
	{
		if (v.size() == 0)
		{
			v.push_back(val);
		}
		else 
		{
			auto it = v.begin();
			while (it != v.end() && *it < val) {
				it++;
			}
			v.insert(it, val);
		}
	}

	void rotate(int k) 
	{
		if (v.empty()) 
		{
			return;
		}
		k = k % v.size();
		reverse(v.begin(), v.end());
		reverse(v.begin(), v.begin() + k);
		reverse(v.begin() + k, v.end());
	}

	void Reverse()
	{
		std::reverse(v.begin(), v.end());
	}

	/*void sort()
	{
		std::sort(v.begin(), v.end());
	}*/

	void Print()
	{
		for (auto& e : v)
		{
			cout << e << " ";
		}
		cout << endl;
	}

private:
	vector<T> v;
};
